package com.sky.initialize;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

@Component
public class Animal implements InitializingBean, DisposableBean {
    // PostConstruct注解,PreDestroy注解,提供初始化和销毁方法
    @PostConstruct
    public void init() {
        System.out.println("Animal init method");
    }
    // 销毁方法
    @PreDestroy
    public void PreDestroy() {
        System.out.println("Animal destroy method");
    }


    // 销毁方法
    @Override
    public void destroy() throws Exception {
        System.out.println("Animal destroy method");
    }
    // 初始化方法
    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("Animal afterPropertiesSet method");
    }
}
